package com.lyluly.coursemgmt.servicemodule.iService.serviceImpl;

import com.lyluly.coursemgmt.servicemodule.iDao.StuAttendMapper;
import com.lyluly.coursemgmt.servicemodule.iService.IStuAttendService;
import com.lyluly.coursemgmt.servicemodule.model.StuAttend;
import com.lyluly.coursemgmt.servicemodule.model.StuAttendExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class StuAttendServiceImpl implements IStuAttendService {
    @Autowired
    private StuAttendMapper stuAttendMapper;

    public void addStuAttendRec(StuAttend stuAttend) {
        stuAttend.setCreatetime(new Date());
        stuAttendMapper.insert(stuAttend);
    }

    public void modifyStuAttend(StuAttend stuAttend) {
        stuAttendMapper.updateByPrimaryKeySelective(stuAttend);
    }

    public void removeStuAttend(int stuAttendId) {
        stuAttendMapper.deleteByPrimaryKey(stuAttendId);
    }

    public StuAttend findStuAttendById(int stuAttendId) {
        return stuAttendMapper.selectByPrimaryKey(stuAttendId);
    }

    public List<StuAttend> findStuAttendList() {
        return stuAttendMapper.selectByExample(null);
    }

    public List<StuAttend> findStuAttendListBySId(String sId) {
        StuAttendExample stuAttendExample = new StuAttendExample();
        stuAttendExample.or().andSIdEqualTo(sId);
        return stuAttendMapper.selectByExample(stuAttendExample);
    }

    public List<StuAttend> findStuAttendListByClassId(int lessonId) {
        StuAttendExample stuAttendExample = new StuAttendExample();
        stuAttendExample.or().andLessonIdEqualTo(lessonId);
        return stuAttendMapper.selectByExample(stuAttendExample);
    }
}
